v9.0 (2011) -- 「X3DObject.FindChildren2」を参照
検索基準に一致するX3DObjectオブジェクトの子のX3DObjectをすべて検索します。デフォルトでは、検索は再帰的に行われます。関数は、基準(名前、タイプ、およびファミリ)を満たすオブジェクトをすべて戻します。このメソッドは一般的に、3d
オブジェクトからなるシーンを階層的に移動する際に使用します。
指定されたModelの下のX3DObjectの子をすべて取得するには(すべてのX3DObject内にネストされているもの、X3DObjectの子として関連付けられているものを含む)、引数を指定せずにこのメソッドを呼び出します。シーン内のすべてのX3DObjectオブジェクトを取得する場合は、FindObjectsを使用する方が効率的です。
oReturn = X3DObject.FindChildren( [Name], [Type], [Family], [Recursive] ); |
| パラメータ | タイプ | 詳細 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Name | StringまたはCollectionItem | 名前表現またはCollectionItem。表現にはワイルドカード文字を含めることもできます。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 型 | String | siTypeで定義されているオブジェクトのタイプ。タイプを使用しない場合は空の文字列になります。タイプには、特定の
x3DObject タイプ(siModelType、si3DObjectType
など)とプリミティブタイプ(siPolyMeshType、siSrfMeshPrimType
など)があります。プリミティブタイプを指定した場合は、このタイプのプリミティブが定義されている子オブジェクトのみが関数の対象になります。有効なタイプを以下に示します。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Family | siFamilyまたは siFamilyエレメントのArray |
siFamilyで定義されているファミリの配列、必要ない場合は空の配列。ファミリを使用して検索を絞り込みます。配列には、X3DObject
ファミリ(si3DObjectFamilyなど)やプリミティブファミリ(siNurbsSurfaceMeshFamily、siNullPrimitiveFamilyなど)があります。指定されたファミリに一致する子オブジェクトだけが処理されます。プリミティブファミリを指定した場合は、そのファミリのいずれかに属するプリミティブが定義されているオブジェクトのみが対象になります。有効なファミリを以下に示します。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Recursive | Boolean | True の場合は、再帰的に検索します。False
の場合は、直接の子について検索します。この再帰検索では、オブジェクトの下にネストされている任意のX3DObjectの内容も検索されます。
デフォルト値: True |
NewScene , false
set oRoot = Application.ActiveProject.ActiveScene.Root
oRoot.AddGeometry "Sphere", "MeshSurface", "mySphere"
oRoot.AddGeometry "Cone", "MeshSurface", "myCone"
oRoot.AddGeometry "Cone", "MeshSurface", "anotherCone"
oRoot.AddGeometry "Cube", "NurbsSurface", "myCube"
Application.LogMessage "** 1: Find all objects whose names start with 'Camera' **"
set kids = oRoot.FindChildren( "Camera*" )
for each pip in kids
Application.LogMessage( "Found child: " & pip.Name )
next
Application.LogMessage "** 2: Find all objects of type siLightPrimType **"
set kids = oRoot.FindChildren( , siLightPrimType )
for each pip in kids
Application.LogMessage( "Found child: " & pip.Name )
next
Application.LogMessage "** 3: Find all objects that belong to siNullPrimitiveFamily and siMeshFamily families **"
set kids = oRoot.FindChildren( , , Array( siNullPrimitiveFamily, siMeshFamily ) )
for each pip in kids
Application.LogMessage( "Found child: " & pip.Name )
next
Application.LogMessage "** 4: Find all objects whose names start with 'my' and belong to siMeshFamily family **"
set kids = oRoot.FindChildren( "my*", , Array(siMeshFamily) )
for each pip in kids
Application.LogMessage( "Found child: " & pip.Name )
next
' Expected results:
'INFO : ** 1: Find all objects whose names start with 'Camera' **
'INFO : Found child: Camera_Root
'INFO : Found child: Camera
'INFO : Found child: Camera_Interest
'INFO : ** 2: Find all objects of type siLightPrimType **
'INFO : Found child: light
'INFO : ** 3: Find all objects that belong to siNullPrimitiveFamily and siMeshFamily families **
'INFO : Found child: Camera_Root
'INFO : Found child: Camera_Interest
'INFO : Found child: mySphere
'INFO : Found child: myCone
'INFO : Found child: anotherCone
'INFO : ** 4: Find all objects whose names start with 'my' and belong to siMeshFamily family **
'INFO : Found child: mySphere
'INFO : Found child: myCone
|
/*
Compare this example with the similar example for X3DObject.Children
*/
// Create a sample scene
NewScene( null, false );
var oNull = Application.ActiveSceneRoot.AddNull( "MyNull" );
var oSphere = Application.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "MySphere" );
var oNestedSphere = oNull.AddNull( "NestedNull" );
var oConeInModel = Application.ActiveSceneRoot.AddGeometry( "Cone", "NurbsSurface", "ConeInMdl" );
var oModel = Application.ActiveSceneRoot.AddModel( oConeInModel, "MyModel" );
// FindChildren can be more powerful than X3DObject.Children because by default it will
// recurse through the graph finding all nested children.
PrintChildren( "FindChildren of SceneRoot:", Application.ActiveSceneRoot.FindChildren() ) ;
PrintChildren( "FindChildren of Null:", oNull.FindChildren() ) ;
PrintChildren( "FindChildren of Model:", oModel.FindChildren() ) ;
//Expected Results:
//INFO : FindChildren of SceneRoot
//INFO : Camera_Root
//INFO : Camera
//INFO : Camera_Interest
//INFO : light
//INFO : MyNull
//INFO : NestedNull
//INFO : MySphere
//INFO : MyModel
//INFO : MyModel.ConeInMdl
//INFO : ----------------------------
//INFO : FindChildren of Null
//INFO : NestedNull
//INFO : ----------------------------
//INFO : FindChildren of Model
//INFO : MyModel.ConeInMdl
//INFO : ----------------------------
// Helper function showing the contents of a collection
function PrintChildren( in_msg, in_oChildren )
{
Application.LogMessage( in_msg );
for ( var i=0 ; i<in_oChildren.Count ; i++ ) {
Application.LogMessage( "\t" + in_oChildren.Item(i).FullName );
}
Application.LogMessage( "----------------------------" ) ;
}
|